home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / BoxMaker++ / Typical ƒ / Typicalshell.cp < prev    next >
Encoding:
Text File  |  1995-01-20  |  2.2 KB  |  113 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <Memory.h>
  3. #include <QuickDraw.h>
  4. #include <OSUtils.h>
  5. #include <ToolUtils.h>
  6. #include <Menus.h>
  7. #include <Packages.h>
  8. #include <Traps.h>
  9. #include <Files.h>
  10. #include <Aliases.h>
  11. #include <AppleEvents.h>
  12. #include <GestaltEqu.h>
  13. #include <Processes.h>
  14. #include <Fonts.h>
  15. #include <OSEvents.h>
  16. #include <Resources.h>
  17. #include <Desk.h>
  18.  
  19. #include "boxmaker constants.h"
  20. #include "boxmaker.h"
  21. #include "preferences.cp"
  22. #include "typicalshell.h"
  23.  
  24. #pragma template_access public
  25.  
  26. void main();
  27.  
  28. void main()
  29. {
  30.     typicalshell it;
  31.     it.run();
  32. }
  33.  
  34. const int    typicalshell::kOurQuitItem = 3;
  35. const OSType typicalshell::dontChange   = '****';
  36.  
  37. typicalshell::typicalshell() : boxmaker()
  38. {
  39.     #ifdef ppcinterfaces
  40.         const StringPtr appname = LMGetCurApName();
  41.     #else
  42.         //
  43.         // For some reason 'curApName' is not declared under SC++
  44.         // This doesn't bother me; I know how to find it, anyway.
  45.         // #include <LoMem.h>
  46.         // const StringPtr appname = (StringPtr)curApName;
  47.         const StringPtr appname = (StringPtr)0x910;
  48.     #endif    
  49.     if( *appname < 8)
  50.     {
  51.         SysBeep( 9);
  52.         SysBeep( 9);
  53.         SysBeep( 9);
  54.         ExitToShell();
  55.     }
  56.     #ifdef ppcinterfaces
  57.         BlockMoveData( &appname[ 1], &typeToSet   , sizeof( typeToSet));
  58.         BlockMoveData( &appname[ 5], &creatorToSet, sizeof( creatorToSet));
  59.     #else
  60.         BlockMove( &appname[ 1], &typeToSet   , sizeof( typeToSet));
  61.         BlockMove( &appname[ 5], &creatorToSet, sizeof( creatorToSet));
  62.     #endif
  63. }
  64.  
  65. void typicalshell::OpenDoc( Boolean opening)
  66. {
  67.     if( opening)
  68.     {
  69.         if( creatorToSet != dontChange)
  70.         {
  71.             theCInfoPBRec.hFileInfo.ioFlFndrInfo.fdCreator = creatorToSet;
  72.         }
  73.         if( typeToSet != dontChange)
  74.         {
  75.             theCInfoPBRec.hFileInfo.ioFlFndrInfo.fdType = typeToSet;
  76.         }
  77.         const OSErr result = PBSetCatInfoSync( &theCInfoPBRec);
  78.         if( result != noErr)
  79.         {
  80.             SysBeep( 9);
  81.         }
  82.     }
  83. }
  84.  
  85. void typicalshell::DoMenu( long retVal)
  86. {
  87.     const short menuID = HiWord( retVal);
  88.     const short itemID = LoWord( retVal);
  89.     switch( menuID)
  90.     {
  91.         case kAppleMenuID:
  92.             DoAppleMenu( itemID);
  93.             break;
  94.             
  95.         case kFileMenuID:
  96.             switch( itemID)
  97.             {
  98.                 case kSelectFileItem:
  99.                     SelectFile();
  100.                     break;
  101.             
  102.                 case kOurQuitItem:        // NB: not kQuitItem!
  103.                     SendQuitToSelf();
  104.                     break;
  105.             }
  106.             break;
  107.         
  108.         default:
  109.             break;            
  110.     }
  111.     HiliteMenu( 0);
  112. }
  113.